<!--
*@Author: QWP
*@Description: 短信接收人维护
*@Date: 2024-07-08 09:51:28
-->
<template>
  <a-layout class="f-h-100 s-bg-white" id="test">
    <u-collapsed-sider style="padding-left: 12px;">
      <u-tree :tree-data="treeData" 
        title="区划"
        v-if="!collapsed">
      </u-tree>
    </u-collapsed-sider>
    <a-layout class=" s-bg-white">
      <u-search-header>
        <u-form
          :model="searchF"
          :gutter="16"
          :elements="searchEl"
          class="f-w-auto">
          <a-col>
            <u-icon-button>查询</u-icon-button>
          </a-col>
          <a-col flex="1">
            <a-row justify="end">
              <a-space>
                <u-icon-button itype="add" @click="showEdit = true">新增</u-icon-button>
                <u-icon-button itype="edit" @click="showEdit = true">修改</u-icon-button>
                <u-icon-button itype="delete" @click="">删除 </u-icon-button>
                <u-icon-button class="f-fr" @click="">模版下载</u-icon-button>
                <u-icon-button itype="import" @click="showImp = true">导入</u-icon-button>
              </a-space>
            </a-row>
          </a-col>
        </u-form>
      </u-search-header>
      <a-layout-content class="f-padding-rl24">
        <u-table
          :columns="columns"
          :data="tabData"
          v-model:pagination="pagenation"></u-table>
      </a-layout-content>
    </a-layout>
  </a-layout>

  <!-- 编辑弹窗 -->
  <Edit v-model:open="showEdit"
    width="800px"
    :title="dialogTitle" />
  
  <!-- 导入 -->
  <u-imp-data v-model:open="showImp"></u-imp-data>
</template>

<script lang="ts" setup>
import { ref, reactive, computed, onMounted, h, watch } from "vue";
import { useRoute, useRouter, onBeforeRouteUpdate, onBeforeRouteLeave} from "vue-router";
import { _IFormEl } from "@/components/common/form/interface";
import { ColProps, FormItemProps, Switch, TableColumnProps, TreeProps } from "ant-design-vue";
import { CheckCircleOutlined, ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { numberC } from '@/util/common'
import { formatAmt, } from '@/util/format.ts'
import dayjs from "dayjs";
import Edit from './Edit.vue'
import { cloneDeep } from 'lodash'
const route = useRoute();
const router = useRouter();

onMounted(() => {
})

const collapsed = ref<boolean>(false)
const treeData: TreeProps['treeData'] = [
  { title: '一级部门', key: '1', 
    children: [
      { title: '二级部门', key: '1-1', },
      { title: '三级部门', key: '1-2', }
    ] 
  },
  { title: '四级部门', key: '2', },
  { title: '五级部门', key: '3', },
] 

let pagenation = reactive({
  total: 0,
  current: 1,
  pageSize: 50,
  showTotal: total => `共 ${total} 条`
})
const searchF = reactive({
  model: {
    fwzh: "",
    fwzh1: "",
  },
});
const formItemProps: FormItemProps = {
  labelCol: { span: 8 },
  wrapperCol: { span: 16 },
};
const searchEl: Array<_IFormEl> = [
  { label: "模糊查询", key: "option", element: "input", col: { span: 4 }, formItemProps: formItemProps, },
];

// 列表
const tabData = reactive([
  { a: "单位1", b: "部门2", b1: '测试', b2: '测试员', b3: '主要领导', b9: '15758844291',
    b4: '暂无备注内容', b5: '启用',
  },
  { a: "单位1", b: "部门2", b1: '测试', b2: '测试员', b3: '主要领导', b9: '15758844291',
    b4: '暂无备注内容', b5: '停用',
  },
]);
let columns: Array<TableColumnProps> = reactive([
  { dataIndex: "a", title: "单位", width: 100 },
  { dataIndex: "b", title: "部门", width: 100 },
  { dataIndex: "b1", title: "姓名", width: 150 },
  { dataIndex: "b2", title: "职务", width: 150 },
  { dataIndex: "b3", title: "职务分类", width: 150 },
  { dataIndex: "b9", title: "手机号", width: 150 },
  { dataIndex: "b4", title: "备注", width: 150 },
  { dataIndex: "b5", title: "启用状态", width: 150,
    customRender: ({text}) => {
      return h(Switch, { checked: text == '启用', checkedChildren: '停用', unCheckedChildren: '启用' })
    }
  },
]);

// 编辑
let dialogTitle = ref<string>("短信接收人编辑")
let showEdit = ref<boolean>(false)

// 导入
let showImp = ref<boolean>(false)

</script>

<style lang="scss" scoped>
.icons-list :deep(.anticon) {
  margin-right: 6px;
  font-size: 24px;
}
</style>
